import service from "@/utils/request"

import LoginWork from "@/utils/LoginWork" 

// 请购查询
export interface RequisitionEnquiryParms{
    color:string,
    lotNo:string,
    mtlName:string,
    pageNum:number,
    pageSize:number,
    style:string
}

export interface RequisitionEnquiryInterface{
    total?: number,
    dtos: dtosList[]
}

export interface dtosList{
    slipType: string,
    lotNo: string,
    sumNo: null,
    reqNo: null,
    style: 167178,
    custom: string,
    mtlNo: string,
    mtlType: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: null,
    mtlUnit: string,
    reqDate: null,
    ttlUsage: number,
    companyId: string,
    styleColor: string,
    purFlag: null,
    yqty: null
}


export const RequisitionEnquiry = (parms:RequisitionEnquiryParms) => {
    return service.put<any,RequisitionEnquiryInterface>('/pcFactorStockQuery/getFdRqsQuery',parms)
}

// 下单批处理
export interface date{
    code:number,
    data:string,
    message:string
}

export const OrderBatchProcessing = (parms:any) => {
    return LoginWork.put<any,date>('/pcFactorStockQuery/fdPurDisAdd',parms)
}

// 我的订购单
export interface MyPurchaseOrderParms{
    flag1:number | string,
    flag2:number | string,
    mtlType:string,
    pageNum:number,
    pageSize:number,
    purColor:string,
    purDateEnd:string,
    purDateStart:string,
    purLot:string,
    purNo:string,
    purStyle:string,
    purType:string,
    vendorNo:string
}

export interface MyPurchaseOrderInterface{
    total?: number,
    dtos: dtos[]
}

interface dtos{
    purType: string,
    purStyle: string,
    purColor: string,
    purLot: string,
    mtlType: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: null,
    mtlUnit: string,
    purNo: null,
    purDate: null | string,
    qty: number,
    overQty: null,
    minusQty: null,
    purQty: number,
    vendorNo: null,
    vendorName: null,
    vendorDate: null | string,
    inDate: null,
    purMemo: null,
    expDate: null,
    mtlNo: string,
    reqNo: string,
    reqDept: null,
    reqDeptName: null,
    reqDate: null,
    reqRta: null,
    reqMemo: null,
    companyId: string
    mtUnit:string
    dept:string
    cancelQty:string
    remark:string
}

export const MyPurchaseOrder = (parms:MyPurchaseOrderParms) => {
    return service.put<any,MyPurchaseOrderInterface>('/pcFactorStockQuery/getOrdQuery',parms)
}

// 指令明细查询
export const InstructionDetailQuery = (reqNo:string,purLot:string,mtlNo:string) => {
    return service.post<any,any>(`/pcFactorStockQuery/getFdLotDetQuery?reqNo=${reqNo}&purLot=${purLot}&mtlNo=${mtlNo}`)
}

// 贴合子材料查询
export const FitSubMaterialQuery = (reqNo:string,purLot:string,mtlNo:string) => {
    return service.post<any,any>(`/pcFactorStockQuery/getFdMtlSumQuery?reqNo=${reqNo}&purLot=${purLot}&mtlNo=${mtlNo}`)
}

// 分类
export const classifyQuery = () => {
    return service.post<any,any>(`/back/getMtlType?levelCode=${2}`)
}

// 厂商
export const VendorQuery = () => {
    return service.get<any,any>(`/back/vendorQuery`)
}

// 出库处理
export const BatchProcessingOutOfStorage = (parms:any) => {
    return LoginWork.put<any,date>('/pcFactorStockQuery/creatPurUpdate',parms)
}

// 出库批处理
export const BatchProcessingOutOfStorage1 = (parms:any,flag?:number) => {
    return LoginWork.put<any,date>(`/pcFactorStockQuery/fdMtlSumUpdate?flag=${flag}`,parms)
}

// 备注查询
export const RemarkQuery = () => {
    return service.get<any,any>(`/pcFactorStockQuery/getFitReamarkQuery`)
}

// 出库单取消
export const TheDeliveryOrderIsCancelled = (slipNo:string) => {
    return service.post<any,date>(`/pcFactorStockQuery/fdMtlSumCancel?slipNo=${slipNo}`)
}

// 打印数据
export const printList = (type:number,purNo:any) => {
    return LoginWork.post<any,any>(`/pcFactorStockQuery/getOrdPrint?type=${type}`,purNo)
}

// 退单
export const returnOrder = (parms:any) => {
    return LoginWork.get<any,date>(`/pcFactorStockQuery/getPurBack?id=${parms}`) 
}